package worldModel;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class SaveOpenHelper {
    public static Navigator openGame() {

	Navigator nav = null;

	ObjectInputStream ois = null;
	try {
	    ois = new ObjectInputStream(new FileInputStream(new File(
		    "navigator.dat")));
	    try {
		nav = (Navigator) ois.readObject();
	    } catch (ClassNotFoundException e) {
		System.out.println("Aww Snap!");
		e.printStackTrace();
	    }
	} catch (FileNotFoundException e) {
	    e.printStackTrace();
	} catch (IOException e) {
	    e.printStackTrace();
	}

	return nav;
    }
    
    public static void saveNewNavigator() {
	
	File f = new File("navigator.dat");

	ObjectOutputStream outputStream = null;
	try {
	    outputStream = new ObjectOutputStream(new FileOutputStream(
		    f));
	    outputStream.writeObject(new Navigator());
	} catch (FileNotFoundException e) {
	    e.printStackTrace();
	} catch (IOException e) {
	    e.printStackTrace();
	}

    }
    
public static void saveGame(Navigator n) {
	
	File f = new File("navigator.dat");

	ObjectOutputStream outputStream = null;
	try {
	    outputStream = new ObjectOutputStream(new FileOutputStream(
		    f));
	    outputStream.writeObject(n);
	} catch (FileNotFoundException e) {
	    e.printStackTrace();
	} catch (IOException e) {
	    e.printStackTrace();
	}

    }
    
    public static void deleteGame() {

    }
}
